package org.september.pisces.user.permission.controller;

import org.september.pisces.user.permission.service.UserOnlineStatusService;
import org.september.pisces.user.permission.utils.UserSessionHelper;
import org.september.simpleweb.auth.DefaultMethod;
import org.september.simpleweb.model.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("userPermission")
public class UserOnlineStatusController {

	@Autowired
    private UserOnlineStatusService userOnlineStatusService;
	
	@RequestMapping("/web/heartBeat")
    @DefaultMethod
    public ResponseVo<String> webHeartBeat() {
    	userOnlineStatusService.webUserHeartBeat(UserSessionHelper.getLoginUid());
    	return ResponseVo.<String>BUILDER().setData("").setCode(ResponseVo.BUSINESS_CODE.SUCCESS);
    }
	
	@RequestMapping("/app/heartBeat")
    @DefaultMethod
    public ResponseVo<String> appHeartBeat() {
    	userOnlineStatusService.appUserHeartBeat(UserSessionHelper.getLoginUid());
    	return ResponseVo.<String>BUILDER().setData("").setCode(ResponseVo.BUSINESS_CODE.SUCCESS);
    }
}
